/**
 * @Description: 验证车牌号码
 * @param {String} val 车牌
 * @return {Boolean}
 */
export const isCarNum = (val: string) => {
  const reg =
    /^(([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z](([0-9]{5}[DF])|([DF]([A-HJ-NP-Z0-9])[0-9]{4})))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳使领]))$/;
  return reg.test(val);
};

/**
 * @description 验证电话号码
 * @param {String} val 电话号码
 * @return {Boolean}
 */
export const isPhoneNumber = (val: string) => {
  const reg =
    /(^0?1[2,3,5,6,8,9]\d{9}$)|(^(\d{3,4})-(\d{7,8})$)|(^(\d{7,8})$)|(^(\d{3,4})-(\d{7,8})-(\d{1,4})$)|(^(\d{7,8})-(\d{1,4})$)/;
  return reg.test(val);
};

/**
 * @Description: 判断是否是非零开头的正数
 * @param {String} val
 * @return {Boolean}
 */
export const isPositiveNumber = (val: string) => {
  const reg = /^([1-9][0-9]*)+(\.\d{1,2})?$/;
  return reg.test(val);
};

/**
 * @Description: 判断是否是非零开头的正整数
 * @param {String} val
 * @return {Boolean}
 */
export const isIntegerNumber = (val: string) => {
  const reg = /^([1-9][0-9]*)$/;
  return reg.test(val);
};
